from aiogram import types, Dispatcher
from aiogram.dispatcher import FSMContext
from aiogram.dispatcher.filters import Text

# from utils.db_api import quick_commands as commands


# async def cmd_start(message: types.Message, state: FSMContext):
#     await state.finish()
#     try:
#         user = await commands.select_user(message.from_user.id)
#         if user.status == 'active':
#             await message.answer(f'Привет {user.first_name}\n'
#                                  f'Ты уже зарегистрирован')
#     except Exception:
#         await commands.add_user(user_id=message.from_user.id,
#                                 first_name=message.from_user.first_name,
#                                 last_name=message.from_user.last_name,
#                                 username=message.from_user.username,
#                                 status='active')
#         await message.answer('Ты успешно зарегистрирован')


async def cmd_cancel(message: types.Message, state: FSMContext):
    await state.finish()
    await message.answer("Действие отменено", reply_markup=types.ReplyKeyboardRemove())


def register_handlers_common(dp: Dispatcher):
    # dp.register_message_handler(cmd_start, commands="start", state="*")
    dp.register_message_handler(cmd_cancel, commands="cancel", state="*")
    dp.register_message_handler(cmd_cancel, Text(equals="отмена", ignore_case=True), state="*")
